#include <iostream.h>
#include <string.h>

#include "stack.h"
#include "queue.h" 
#include "datacell.h" 
#include "pgmcell.h"
#include "dictcell.h"
#include "forth.h"

main( int ac , char ** av )
{
   cerr << "Forth interpreter - G.Turani" << endl ;

   // inserimento di info in dizionario
//   dictionary.insert( dictionary_cell( "GIPI" ) ) ;
   
   // costruzione di un programma forth
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_SPACE ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_INT , 3 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_SPACES ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_CR ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_VLIST ) ) ;
   
   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_COLON) ) ;
   pgm.insert( pgmcell( pgmcell::TK_ID , "ASTERISCO" ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_CR ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_VLIST ) ) ;
   
   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_ID , "ASTERISCO" ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_COLON) ) ;
   pgm.insert( pgmcell( pgmcell::TK_ID , "2ASTERISCHI" ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;
//   pgm.insert( pgmcell( pgmcell::TK_CR ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_ID , "2ASTERISCHI" ) ) ;
   
   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_VLIST ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_COLON) ) ;
   pgm.insert( pgmcell( pgmcell::TK_ID , "3ASTERISCHI" ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_ID , "2ASTERISCHI" ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_ID , "3ASTERISCHI" ) ) ;
  
   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_VLIST ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_COLON) ) ;
   pgm.insert( pgmcell( pgmcell::TK_ID , "6ASTERISCHI" ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_INT , 42 ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_EMIT ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_ID , "2ASTERISCHI" ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_ID , "3ASTERISCHI" ) ) ;
   pgm.insert( pgmcell( pgmcell::TK_CR ) ) ;

   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_ID , "6ASTERISCHI" ) ) ;
  
   interpreter.execute( pgm ) ;

   pgm.insert( pgmcell( pgmcell::TK_VLIST ) ) ;

   interpreter.execute( pgm ) ;

   //interpreter.save( "forth.db" ) ;

   return 0 ;
}